#ifndef __PROCESS_POOL_HPP__
#define __PROCESS_POOL_HPP__

#include <iostream>
#include <cstdlib>
#include <vector>
#include <unistd.h>
#include <sys/wait.h>

class Channel
{
public:
    Channel()
    {
        
    }
    ~Channel()
    {
    }

private:
    int _wfd;
    pid_t _subid;
    std::string _name;
};

class ChannelManager
{
public:
    ChannelManager()
    {
    }
    ~ChannelManager()
    {
    }

private:

};

class ProcessPool{
public:
    ProcessPool(int num):_process_num(num)
    {
    }
    ~ProcessPool()
    {
    }

    bool start(){
        int fds[2];
        int n = pipe(fds);
        if(n<0){
            perror("pipe error:");
            return false;
        }

        //创建子进程
        int pid = fork();
        if(pid<0){
            perror("fork error:");
            return false;
        }
        else if(pid == 0){
            close(fds[1]);
            //work();
            close(fds[0]);
            exit(0);
        }else{
            close(fds[0]);

        }
        return true;
    }
private:  
    int _process_num;
    ChannelManager _cm;
};

#endif